//#include <stdio.h>
//
//long long max(long long a, long long b)
//{
//    return a > b ? a : b;
//}
//
//int main() 
//{
//    int n;
//    scanf_s("%d", &n);
//
//    long long current_sum = 0;
//    long long max_sum = -10000000000LL; 
//
//    for (int i = 0; i < n; i++) 
//    {
//        long long num;
//        scanf_s("%lld", &num);
//
//        current_sum = max(num, current_sum + num);
//
//        max_sum = max(max_sum, current_sum);
//    }
//    printf("%lld\n", max_sum);
//    return 0;
//}

//#include <stdio.h>
//
//int main() {
//    long long a, b;
//    scanf_s("%lld %lld", &a, &b);
//    printf("%lld\n", 2 * b - a);
//    return 0;
//}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define ull unsigned long long

const ull base = 131;
const ull mod = 1000000000000000003ULL;

ull pow_mod(ull a, ull b, ull mod) {
    ull res = 1;
    while (b) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

typedef struct {
    ull* data;
    int size;
} HashArray;

HashArray compute_hashes(char* s, int L) {
    HashArray result;
    result.data = NULL;
    result.size = 0;
    int len = strlen(s);
    if (len < L)
        return result;

    ull high_base = pow_mod(base, L - 1, mod);
    ull* hashes = (ull*)malloc(sizeof(ull) * (len - L + 1));
    ull hash_val = 0;
    for (int i = 0; i < L; i++) {
        hash_val = (hash_val * base + s[i]) % mod;
    }
    hashes[0] = hash_val;
    int count = 1;
    for (int i = L; i < len; i++) {
        hash_val = (hash_val - s[i - L] * high_base % mod + mod) % mod;
        hash_val = (hash_val * base + s[i]) % mod;
        hashes[count++] = hash_val;
    }
    result.data = hashes;
    result.size = count;
    return result;
}

typedef struct {
    ull* array;
    int size;
    int capacity;
} HashSet;

HashSet create_hashset(int capacity) {
    HashSet set;
    set.array = (ull*)malloc(capacity * sizeof(ull));
    set.size = 0;
    set.capacity = capacity;
    return set;
}

void insert(HashSet* set, ull value) {
    if (set->size == set->capacity) {
        set->capacity *= 2;
        set->array = (ull*)realloc(set->array, set->capacity * sizeof(ull));
    }
    set->array[set->size++] = value;
}

int contains(HashSet* set, ull value) {
    for (int i = 0; i < set->size; i++) {
        if (set->array[i] == value)
            return 1;
    }
    return 0;
}

void intersect(HashSet* set, HashSet* other) {
    int j = 0;
    for (int i = 0; i < set->size; i++) {
        if (contains(other, set->array[i])) {
            set->array[j++] = set->array[i];
        }
    }
    set->size = j;
}

void free_hashset(HashSet* set) {
    free(set->array);
    set->array = NULL;
    set->size = set->capacity = 0;
}

int main() {
    int n;
    scanf_s("%d", &n);
    getchar();

    char** arr = (char**)malloc(n * sizeof(char*));
    int min_len = 10000000;
    for (int i = 0; i < n; i++) {
        char buffer[1000010];
        fgets(buffer, 1000010, stdin);
        size_t len = strlen(buffer);
        if (buffer[len - 1] == '\n') {
            buffer[len - 1] = '\0';
            len--;
        }
        arr[i] = strdup(buffer);
        if (len < min_len)
            min_len = len;
    }

    if (min_len == 0) {
        printf("\n");
        for (int i = 0; i < n; i++)
            free(arr[i]);
        free(arr);
        return 0;
    }

 /*   int low = 1, high = min_len;
    char* ans = NULL;
    while (low <= high) {
        int mid = (low + high) / 2;
        char* s0 = arr[0];
        HashArray s0_hashes = compute_hashes(s0, mid);
        if (s0_hashes.size == 0) {
            free(s0_hashes.data);
            high = mid - 1;
            continue;
        }

        HashSet common_set = create_hashset(s0_hashes.size);
        for (int i = 0; i < s0_hashes.size; i++) {
            insert(&common_set, s0_hashes.data[i]);
        }

        int valid = 1;
        for (int i = 1; i < n; i++) {
            HashArray hashes = compute_hashes(arr[i], mid);
            if (hashes.size == 0) {
                valid = 0;
                free(hashes.data);
                break;
            }

            HashSet set_i = create_hashset(hashes.size);
            for (int j = 0; j < hashes.size; j++) {
                insert(&set_i, hashes.data[j]);
            }

            intersect(&common_set, &set_i);
            free(hashes.data);
            free_hashset(&set_i);
            if (common_set.size == 0) {
                valid = 0;
                break;
            }
        }

        if (valid && common_set.size > 0) {
            for (int i = 0; i < s0_hashes.size; i++) {
                if (contains(&common_set, s0_hashes.data[i])) {
                    ans = (char*)malloc(mid + 1);
                    strncpy(ans, s0 + i, mid);
                    ans[mid] = '\0';
                    break;
                }
            }
            if (ans) {
                printf("%s\n", ans);
                free(ans);
                free(s0_hashes.data);
                free_hashset(&common_set);
                for (int i = 0; i < n; i++)
                    free(arr[i]);
                free(arr);
                return 0;
            }
        }

        free(s0_hashes.data);
        free_hashset(&common_set);
        low = mid + 1;
    }

    printf("\n");
    for (int i = 0; i < n; i++)
        free(arr[i]);
    free(arr);
    return 0;
}*/